
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "ply_funcs.lua" )

include( 'shared.lua' )
include( 'money.lua' )
include( 'chatsounds.lua' )
include( 'util.lua' )

// Serverside only stuff goes here
//models/props_lab/binderblue.mdl - credit card
/*models/player/Group01/Female_01.mdl
models/player/Group01/Female_02.mdl
models/player/Group01/Female_03.mdl
models/player/Group01/Female_04.mdl
models/player/Group01/Female_06.mdl
models/player/Group01/Female_07.mdl*/

//models/props_lab/monitor02.mdl
//models/props_c17/cashregister01a.mdl
//models/props_wasteland/controlroom_desk001a.mdl

//make smartness test


function GM:PlayerHurt( ply )

	self.BaseClass:PlayerHurt( ply )
	ply:EmitSound( "vo/npc/male01/pain0"..math.random( 1, 9 )..".wav" )
	
end	

function GM:DoPlayerDeath( ply, attacker, dmginfo )

	ply:CreateRagdoll()
	ply:CleanUp()

end


function GM:PlayerDeathSound( ply )

	ply:EmitSound( "vo/npc/Barney/ba_ohshit03.wav" )
	return true
	
end

function GM:PlayerInitialSpawn( ply )

	self.BaseClass:PlayerInitialSpawn(ply)
	
	ply.playerModel = "models/player/Group01/Male_0"..math.random(1, 9)..".mdl"
	ply:CreateBankAccount()
	
end

function GM:PlayerSpawn( ply )

	ply:SetModel(ply.playerModel)
	ply:SetHealth(math.random(60, 90))
	
	ply:SetNWInt("hunger", 100)
	ply:SetNWInt("thirst", 100)
	
	GAMEMODE:SetPlayerSpeed(ply, 125, 250)

end

function GM:GetFallDamage( ply, vel )
 
	vel = vel - 580
	return vel*(100/(1024-580))

end

function GM:Think()

	self.BaseClass:Think()

	for k, v in pairs(player.GetAll()) do
	
		v:Think()
	
	end

end

function GM:PlayerCanHearPlayersVoice( pListener, pTalker )

	for k, v in pairs(ents.FindInSphere(pTalker:GetPos(), 500)) do
	
		if (v == pTalker) then
		
			return true
			
		end
	
	end
	
	return false

end

function GM:KeyPress(ply, key)

	self.BaseClass:KeyPress(ply, key)

end

function GM:KeyRelease(ply, key)

end

function GM:PlayerSwitchFlashlight(ply, SwitchOn)

	return false
	
end

local lessDamage = {HITGROUP_LEFTARM, HITGROUP_RIGHTARM, HITGROUP_LEFTLEG, HITGROUP_RIGHTLEG}

function GM:ScalePlayerDamage( ply, hitgroup, dmginfo )

	self.BaseClass:ScalePlayerDamage( ply, hitgroup, dmginfo )
	
	if (hitgroup == HITGROUP_HEAD) then
	
		dmginfo:ScaleDamage(3)
		
	elseif (hitgroup == HITGROUP_CHEST) then
	
		dmginfo:ScaleDamage(1.5)
	
	else
	
		for k, v in pairs(lessDamage) do
		
			if (hitgroup == v) then

				dmginfo:ScaleDamage( 0.25 )
				
			end
			
		end
		
	end
 
end

function GM:SetPlayerAnimation( ply, weapanim )

	self.BaseClass:SetPlayerAnimation( ply, weapanim )
	
	if (ply.sitting) then
	
		local seq = ply:LookupSequence( "sit" )	
		ply:SetPlaybackRate( 1 )	
		ply:ResetSequence( seq )
		ply:SetCycle( 1 )
		
	end

end

function GM:PlayerCanPickupWeapon(ply, wep)

	local actwep = ply:GetActiveWeapon()
	
	if (actwep:IsValid()) then
	
		ply:DropWeapon(actwep)
	
	end
	
	return true
	
end